package com.bluestone.run;

import java.util.List;

import com.bluestone.context.CommandContext;
import com.bluestone.context.IContext;
import com.bluestone.context.TestCaseContext;
import com.bluestone.scripts.Command;
import com.bluestone.scripts.TestCase;
import com.bluestone.util.Util;

public class TestCaseController extends BaseController {

	@Override
	boolean executeContext(IContext context) {
		boolean flag =false;
		TestCaseContext testcaseContext = (TestCaseContext)context;
		TestCase testcase = testcaseContext.getTestcase();
		testcaseContext.addExecuteLog("run testcase "+testcase.getName());
		List commands = testcase.getCommands();
		CommandController controller = new CommandController();
		for(int i=0; i<commands.size(); i++){
			Command command = (Command)commands.get(i);
			CommandContext temp = testcaseContext.getCommandContext(command);
			flag = controller.execute(temp);
			if (!flag) {
				flag = false;
				break;
			}			
			
		}
		testcaseContext.addExecuteLog("run testcase "+testcase.getName()+"-->"+flag);
		return flag;
		
	}



}
